<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function timeout(delay = 10) {
      return new Promise((resolve)=>{
        setTimeout(resolve,delay)
      })
    }
    timeout(2000)
    .then(value=>{
      console.log(1);
      return timeout(2000)
    })
    .then(()=>{
      console.log(2);
      
    })
  </script>
</body>
</html>